# Calculate the alcohol content of beer
module Alcohol

  # Calculates alcohol by weight
  #
  # @note
  #     Extract must be measured in Plato
  #
  # @example
  #     Alcohol.by_weight 15, 3
  #
  # @param [Float] original original Plato
  # @param [Float] terminal terminal Plato
  # @return [Float] alcohol content by weight
  def self.by_weight original, terminal
    ((original - ((0.1808 * original) + (0.8192 * terminal))) /
     (2.0665 - (0.010665 * original))).round 1
  end

  # Calculates alcohol by volume
  #
  # @note
  #     Extract must be measured in Plato
  #
  # @example
  #     Alcohol.by_volume 17.5, 3.2
  #
  # @param [Float] original original Plato
  # @param [Float] terminal terminal Plato
  # @return [Float] alcohol content by volume
  def self.by_volume original, terminal
    ((by_weight original, terminal) / 0.793573).round 1
  end

end
